import { Body, Controller, Post, Get, Patch, Param, Delete } from '@nestjs/common';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { NotificationService } from './notification.service';
import { ICreateNote, IUpdateNote } from './notification.dto';

@ApiTags('notification')
@Controller('notification')
export class NotificationController {
    constructor(private notificationService: NotificationService) {}

    @ApiOperation({
        description: 'create note',
    })
    @Post('add-note/:userTelegramId')
    async createNote(@Param('userTelegramId') userTelegramId: string, @Body() data: ICreateNote) {
        return await this.notificationService.createNote(userTelegramId, data);
    }

    @ApiOperation({
        description: 'get all notes by user',
    })
    @Get('get-list-notes/:userTelegramId')
    async getNotesByUser(@Param('userTelegramId') userTelegramId: string) {
        return await this.notificationService.getNotesByUser(userTelegramId);
    }

    @ApiOperation({
        description: 'get all notes on tomorrow by user, mode: 0 - today, 1 - tomorrow',
    })
    @Get('get-list-tomorrow-notes/:mode')
    async getNotesOnTomorrowByUser(@Param('mode') mode: string) {
        return await this.notificationService.getNotesOnTomorrowByUser(mode);
    }

    @ApiOperation({
        description: 'update data note',
    })
    @Patch('update-note/:userTelegramId/:noteId')
    async updateNote(
        @Param('userTelegramId') userTelegramId: string,
        @Param('noteId') noteId: string,
        @Body() data: IUpdateNote
    ) {
        return await this.notificationService.updateNote(userTelegramId, noteId, data);
    }

    @ApiOperation({
        description: 'delete note',
    })
    @Delete('delete-note/:userTelegramId/:noteId')
    async deleteNote(@Param('userTelegramId') userTelegramId: string, @Param('noteId') noteId: string) {
        return await this.notificationService.deleteNote(userTelegramId, noteId);
    }
}
